import java.util.Comparator;
import java.util.PriorityQueue;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 28779
 * Date: 2023-05-12
 * Time: 13:05
 */

/**
 * imp实现comparator接口
 * o2 - o1是大根堆
 * o1 - o2是小跟堆
 */
class imp implements Comparator<Integer> {
    @Override
    public int compare(Integer o1, Integer o2) {
        return o2 - o1;
    }
}
public class TestPriorityQueue {

    public static void main(String[] args) {
        PriorityQueue<Integer> priorityQueue = new PriorityQueue<>(new imp());

        priorityQueue.offer(2);
        priorityQueue.offer(1);
        priorityQueue.offer(11);

        System.out.println(priorityQueue.poll());
        System.out.println(priorityQueue.poll());
        System.out.println(priorityQueue.poll());

/*        Queue<Integer> priorityQueue1 = new PriorityQueue<>();
        priorityQueue1.offer(11);
        priorityQueue1.offer(2);
        priorityQueue1.offer(3);

        System.out.println(priorityQueue1.poll());
        System.out.println(priorityQueue1.poll());
        System.out.println(priorityQueue1.poll());*/
    }
}
